extends Node2D

func _ready() -> void:
    var anim_sprite := AnimatedSprite.new()
        var sprite_frames := SpriteFrames.new()
        sprite_frames.add_animation("idle")
        sprite_frames.set_animation_loop("idle",true)
        var texture_size := Vector2(64,64)
        var sprite_size := Vector2(32,32)
        var full_spritesheet : Texture = load("res://icon.png")
        var num_columns : int = int(texture_size.x/sprite_size.x)
        for x_coords in range(num_columns):
            for y_coords in range(int(texture_size.y/sprite_size.y)):
                var frame_tex := AtlasTexture.new()
                frame_tex.atlas = full_spritesheet
                frame_tex.region = Rect2(Vector2(x_coords,y_coords)*sprite_size,sprite_size)
                sprite_frames.add_frame("idle",frame_tex,y_coords*num_columns+x_coords)
        anim_sprite.frames = sprite_frames
        add_child(anim_sprite)
        anim_sprite.position = Vector2(32,32)
        anim_sprite.play("idle")